<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\ProductImage
 *
 * @property int $id
 * @property int $img_id
 * @property int $order
 * @property int $product_id
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereImgId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOrder($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class ProductImage extends Model
{
    /**
     * @var string
     */
    protected $table= 'product_images';

    /**
     * @var array
     */
    protected $hidden = ['img_id', 'produc_id', 'created_at', 'updated_at'];

    /**
     * 申明和image的一对一的关系
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function imgUrl()
    {
        return $this->hasOne('App\Models\Images', 'id', 'img_id');
    }
}
